﻿using System;
namespace Producers.Taitis.Xtee.Riik.Ee.Producer.Taitis {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="paring4_paring", Namespace="http://producers.taitis.xtee.riik.ee/producer/taitis", Target=typeof(Paring4Paring))]
    public class Paring4ParingSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IParing4Paring clazz;
        
        public Paring4ParingSerializer(IParing4Paring clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("isiku_reg_kood");
            if (clazz.IsikuRegKood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IsikuRegKood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : IsikuRegKood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("eesnimi");
            if (clazz.Eesnimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Eesnimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Eesnimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("perek_arin_nimi");
            if (clazz.PerekArinNimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PerekArinNimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PerekArinNimi");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "isiku_reg_kood")) {
                goto isiku_reg_kood;
            }
            else {
                if ((Reader.LocalName == "eesnimi")) {
                    goto eesnimi;
                }
                else {
                    if ((Reader.LocalName == "perek_arin_nimi")) {
                        goto perek_arin_nimi;
                    }
                    else {
                        return;
                    }
                }
            }
        isiku_reg_kood:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring4_paring>isiku_reg_kood");
            }
            clazz.IsikuRegKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isiku_reg_kood")).Value;
            goto START;
        eesnimi:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring4_paring>eesnimi");
            }
            clazz.Eesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("eesnimi")).Value;
            goto START;
        perek_arin_nimi:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring4_paring>perek_arin_nimi");
            }
            clazz.PerekArinNimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("perek_arin_nimi")).Value;
            goto START;
        }
    }
}
